<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix"><span>店铺入口</span></div>
    <div>
      <el-collapse v-model="activeNames">
        <el-collapse-item title="组件样式" name="1">
          <el-form size="medium" label-width="100px">
            <el-form-item label="组件背景"><ColorPicker :color="data" :name="'bg_color'"></ColorPicker></el-form-item>
            <el-form-item label="商户LOGO">
              <el-radio-group v-model="data.logo_type">
                <el-radio :label="'square'">圆角</el-radio>
                <el-radio :label="'circle'">圆形</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="商户标题"><ColorPicker :color="data" :name="'title_color'"></ColorPicker></el-form-item>
            <el-form-item label="商品数量">
              <el-radio-group v-model="data.shownum">
                <el-radio :label="true">显示</el-radio>
                <el-radio :label="false">不显示</el-radio>
              </el-radio-group>

              <div class="bg-color">
                <el-form size="medium" label-width="100px">
                  <el-form-item label="文字颜色">
                      <ColorPicker :color="data" :name="'num_color'"></ColorPicker>
                   </el-form-item>
                   </el-form>
                   </div>
            </el-form-item>
            <el-form-item label="进店按钮">
              <div class="bg-color">
                <el-form size="medium" label-width="100px">
                  <el-form-item label="类型">
                    <el-radio-group v-model="data.btn.type">
                      <el-radio :label="1">边框按钮</el-radio>
                      <el-radio :label="2">实底按钮</el-radio>
                      <el-radio :label="3">图标</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="图标" v-if="data.btn.type == 3">
                    <div class="icon_box">
                      <span class="hasIcon" v-show="data.btn.icon != ''">
                        <i :class="data.btn.icon"></i>
                        <i class="icon-abl-close el-icon-error" @click="removeIcon()"></i>
                        <span class="choose_bar" @click="chooseIcon"><i class="txt">替换</i></span>
                      </span>
                      <span class="noIcon" v-show="data.btn.icon == ''"><i class="el-icon-plus" style="color:#409EFF;" @click="chooseIcon"></i></span>
                    </div>
                  </el-form-item>
                  <el-form-item label="图标颜色" v-if="data.btn.type == 3"><ColorPicker :color="data.btn" :name="'icon_color'"></ColorPicker></el-form-item>
                  <el-form-item label="按钮文字">
                    <el-input size="medium" placeholder="如:进店" class="" v-model="data.btn.title">
                      <el-button size="medium" @click="data.btn.title = ''" slot="append">重置</el-button>
                    </el-input>
                  </el-form-item>
                  <el-form-item v-if="data.btn.type == 1 || data.btn.type == 3" label="文字颜色"><ColorPicker :color="data.btn" :name="'titlecolor1'"></ColorPicker></el-form-item>
                  <el-form-item v-if="data.btn.type == 2" label="文字颜色"><ColorPicker :color="data.btn" :name="'titlecolor2'"></ColorPicker></el-form-item>
                  <el-form-item label="按钮颜色" v-if='data.btn.type!=3'><ColorPicker :color="data.btn" :name="'color'"></ColorPicker></el-form-item>
                  <el-form-item label="按钮圆角" v-if='data.btn.type!=3'>
                    <div class="slider_box">
                      <el-slider class="slider_item" :max="30" v-model="data.btn.rd"></el-slider>
                      <el-input-number v-model="data.btn.rd" :controls="false" :min="0" :max="30"></el-input-number>
                    </div>
                  </el-form-item>
                </el-form>
              </div>
            </el-form-item>
            <el-form-item label="上间距">
              <div class="slider_box">
                <el-slider class="slider_item" :max="50" v-model="data.p_t"></el-slider>
                <el-input-number v-model="data.p_t" :controls="false" :min="0" :max="50"></el-input-number>
              </div>
            </el-form-item>
            <el-form-item label="下间距">
              <div class="slider_box">
                <el-slider class="slider_item" :max="50" v-model="data.p_b"></el-slider>
                <el-input-number v-model="data.p_b" :controls="false" :min="0" :max="50"></el-input-number>
              </div>
            </el-form-item>
          </el-form>
        </el-collapse-item>
      </el-collapse>
    </div>
  </el-card>
</template>

<script>
import ColorPicker from '@/components/ColorPicker/index';
export default {
  components: {
    ColorPicker
  },
  props: {
    data: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      activeNames: ['1']
    };
  },
  methods: {
    removeIcon(tag) {
      this.data.btn.icon = '';
    },
    //选择图标
    chooseIcon() {
      this.$parent.showiconselcet();
    },
    geticon(data) {
      this.data.btn.icon = data;
    }
  }
};
</script>

<style lang="scss" scoped>
.bg-color {
  border: 1px solid #e9edef;
  box-sizing: border-box;
  padding: 20px 0;
  border-radius: 2px;
  background: #f4f6f8;
}
.icon_box {
  width: 36px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
  border: 1px solid #dcdfe6;
  position: relative;

  .icon-abl-close {
    position: absolute;
    top: -6px;
    right: -9px;
    color: rgba(0, 0, 0, 0.3);
    font-size: 16px;
  }

  &:hover {
    .choose_bar {
      display: block;
    }
  }

  .choose_bar {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    line-height: 18px;
    text-align: center;
    width: 100%;

    i.txt {
      display: inline-block;
      font-style: normal;
      -webkit-transform: scale(0.75);
      transform: scale(0.75);
      letter-spacing: 2px;
    }
  }
}
</style>
